package java101;
// Next week read on object oriented programming. Read book 3 chapters 1 and 2. Assignment 7.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;

public class InClass3 {

	
	private static int fibCount = 0;



	public static void main(String[] args) {

		/*
		ArrayList<String> arrayList = new ArrayList<String>(); 
		arrayList.add("one");
		arrayList.add("two");
		arrayList.add("buckle my shoe");
		for (String s : arrayList){
		System.out.println(s.toUpperCase());
		}
		/*dissimilar strings aren't very useful. Paramaterize it. ex. <String>*/
		
	/*	System.out.println(arrayList.get(2));
		System.out.println(arrayList.contains("two"));
		Object[] array = arrayList.toArray();
		String[] array2 = arrayList.toArray(new String[] {}); //Converts it to an array of Strings.
*/
		
		
		//		to find the # of occurences of something in an array list use maps:
//		HashMap - not sorted - TreeList is
//		Google is basically a gigantic HashMap

		/*
		TreeMap<String,Integer> wordCount = new TreeMap<String,Integer>();
		try {
		FileReader fileReader = new FileReader(
				"//Users//Meg//Downloads//10kwords.txt");
	
		BufferedReader bufferedReader = new BufferedReader(fileReader);
		String word = bufferedReader.readLine();
		while (word != null) {
			String firstLetter = word.substring(0, 1);
			Integer count = wordCount.get(firstLetter);
			if (count != null)
				wordCount.put(firstLetter, ++count);
				else
					wordCount.put(firstLetter, 1);
			
			word = bufferedReader.readLine();
			
		}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e){
			e.printStackTrace();
		}
		
		for (String key : wordCount.keySet()) {
			System.out.println(key + ": " + wordCount.get(key) + ", " + key.hashCode());
		}
		*/
		
		
	/*	
		System.out.println(factorial(6));
		long start = System.currentTimeMillis();
		System.out.println(fib(33));
		long stop = System.currentTimeMillis();
		long time = stop - start;
		System.out.println("Fib got called " + fibCount + " times in " + time + " milliseconds.");
		
		
		
	}

	
//	
	private static int fib(int i) {
		fibCount++;
		if (i < 2)
			return i;
		else
		return fib(i-2) + fib(i-1);
	}



	private static int factorial(int n){
		if (n>0)
			return n * factorial(n-1);
		else 
			return 1;
//		Exit condition is most important part of recursive methods. 
//		Google does recursive stuff to get all web pages. They do that about every two weeks.
 * 
 */
		
		
//		Object Oriented:
		
	}

}
